{extend name="property/public/insidePageBase" /}
{block name="title"}添加文章{/block}
{block name="css"}
{css href="/static/common/js/lay-module/cascader/cascader.css" /}
{css href="/static/common/lib/umeditor/themes/default/css/umeditor.css" /}
{__block__}
{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane">
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="layui-form-item">
                        <label class="layui-form-label required">所属分类</label>
                        <div class="layui-input-block">
                            <select name="cate_id" lay-filter="cate_id" lay-search>
                                <option value="">请选择</option>
                                {foreach $cateData as $v}
                                <option value="{$v['id']}">{$v['name']}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs8">
                    <div class="layui-form-item">
                        <label class="layui-form-label required">封面图片</label>
                        <div class="layui-input-inline">
                            <input type="text" name="picture" placeholder="请上传封面图片" id="picture" class="layui-input">
                        </div>
                        <img class="checkPictureByImg picture" style="width: 80px;height: 40px;">
                        <div class="layui-input-inline layui-btn-container" style="width: auto;">
                            <button type="button" class="layui-btn layui-btn-primary uploadImg" lay-data="{field: 'picture',data:{dir:'article', field:'picture'}}">
                                <i class="layui-icon">&#xe67c;</i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs6">
                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">是否显示</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_show" autocomplete="off" value="1" title="显示" checked>
                            <input type="radio" name="is_show" autocomplete="off" value="2" title="隐藏">
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <div class="layui-form-item" pane="">
                        <label class="layui-form-label">是否置顶</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_top" autocomplete="off" value="1" title="置顶" checked>
                            <input type="radio" name="is_top" autocomplete="off" value="2" title="关闭">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">资讯标题</label>
                <div class="layui-input-block">
                <input type="text" name="title" placeholder="请输入标题" class="layui-input" lay-verify="required" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">资讯关键字</label>
                <div class="layui-input-block">
                    <input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">资讯描述</label>
                <div class="layui-input-block">
                    <input type="text" name="desc" placeholder="请输入描述" class="layui-input" autocomplete="off"/>
                </div>
            </div>

            <div class="layui-form-item" pane="">
                <label class="layui-form-label">打开方式</label>
                <div class="layui-input-block">
                    <input type="radio" name="content_type" lay-filter="content_type" autocomplete="off" value="1" title="本地内容" checked>
                    <input type="radio" name="content_type" lay-filter="content_type" autocomplete="off" value="2" title="外链文章">
                </div>
            </div>
            <div class="layui-form-item content_type_b" style="display: none">
                <label class="layui-form-label">外链地址</label>
                <div class="layui-input-block">
                    <input type="text" name="network_url" placeholder="请输入外链地址" class="layui-input" autocomplete="off"/>
                </div>
            </div>

            <div class="layui-form-item layui-form-text content_type_a">
                <label class="layui-form-label">资讯内容</label>
                <div class="layui-input-block">
                    <textarea id="content" name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <button class="layui-btn" type="button" lay-submit lay-filter="submitBtn" id="submitBtn">提交</button>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
{__block__}
<script src="/static/common/lib/umeditor/umeditor.config.js"></script>
<script src="/static/common/lib/umeditor/umeditor.min.js"></script>
<script>
    layui.use([ 'form',  'upload'], function () {
        var form = layui.form,upload = layui.upload,$ = layui.$;
        var editor = UM.getEditor('content', {
            initialFrameWidth: 766,
            initialFrameHeight: 400,
            zIndex: 1
        })
        $('.uploadImg').selectImages({
            confirm:function(res,elem,data) {
                $('#' + data.field).val(res[0].src);
                $('.' + data.field).attr('src',res[0].src)
            }
        });
        form.on('radio(content_type)', function(data) {
            if(data.value == 1) {
                $('.content_type_b').hide();
                $('.content_type_a').show();
            }
            if(data.value == 2) {
                $('.content_type_b').show();
                $('.content_type_a').hide();
            }
        });
    });
</script>
{/block}